import '../utils/XORCryptoUtil.dart';

/// 创建人： Created by zhaolong
/// 创建时间：Created by  on 2020/7/23.
///
/// 创建人： Created by zhaolong
/// 创建时间：Created by  on 2020/9/25.
///
/// gongzhonghao biglead
/// https://study.163.com/instructor/1021406098.htm
/// https://blog.csdn.net/zl18603543572
/// https://www.toutiao.com/c/user/token/MS4wLjABAAAAYMrKikomuQJ4d-cPaeBqtAK2cQY697Pv9xIyyDhtwIM/

class UserBean {
  int userId;
  String username;
  int userManager;
  String token;
  String mobile;
  String sex;
  String staffNum;
  String headImg;
  int userType;
  int mineId;
  String userPost;
  String userPost_department;
  String idCard;
  String entryTime;
  String factionTime;
  int workingAge;
  String politicsStatus;
  String reamName;
  String ranking;
  String department;
  String autograph;
  String userAddress;
  String birthday;
  String technicalTitle;
  String educationalBackground;
  String honoursAwards;
  int wrongRule;
  String mineName;

  /// 人脸识别开关 默认0开启 ，1关闭
  int userFaceOpen = 0;
  int userBlocType;

  String userImage;

  /// 是否是培训班主任 默认0不是 ；1为是
  int isDirector = 0;

  ///是否是培训教师  默认0不是 ；1为是
  int isTeacher = 0;

  ///0 不是审核默认 1科兴审核 2 伯方
  int isCheck;

  ///对应的审批 默认为0 无审批权限 2为二级审批 1为一级审批
  int isApprove;

  ///是否是ios审核 默认0不是 ；1为是
  int isIosCheck = 0;

  /// 邮箱
  String userMailbox;

  /// 院校
  String userAcademy;

  /// 专业
  String userMajor;

  /// 简历
  String userResume;

  /// 汉族
  String userNation;

  /// 全日制
  String userSchoolNature;

  //头像
  String identifImg;

  /// 班主任  0 APP内容全部显示  1  只显示工作台
  int showDirectorWorkBench = 0;

  /// 教师  0 APP内容全部显示  1  只显示工作台
  int showTeacherWorkBench = 0;

  UserBean(this.username, this.userPost);

  UserBean.fromJson(Map<String, dynamic> map) {
    if (map == null) {
      return;
    }

    this.userMailbox = map["userMailbox"];
    this.userAcademy = map["userAcademy"];
    this.userSchoolNature = map["userSchoolNature"];
    this.userMajor = map["userMajor"];
    this.userNation = map["userNation"];
    this.userResume = map["userResume"];

    this.userFaceOpen = map["userFaceOpen"] ?? 0;
    this.isDirector = map["isDirector"] ?? 0;
    this.isTeacher = map["isTeacher"] ?? 0;

    this.showDirectorWorkBench = map["showDirectorWorkBench"] ?? 0;
    this.showTeacherWorkBench = map["showTeacherWorkBench"] ?? 0;

    this.userManager = map["userManager"] ?? 0;
    this.isIosCheck = map["isIosCheck"] ?? 0;

    this.identifImg = map["identifImg"];
    this.isApprove = map["isApprove"];
    this.userId = map["userId"];
    this.isCheck = map["isCheck"];
    this.username = map["username"];
    this.mobile = map["mobile"];
    this.sex = map["sex"];
    this.staffNum = map["staffNum"];
    this.headImg = map["headImg"];
    this.userType = map["userType"];
    this.mineId = map["mineId"];
    this.userPost = map["userPost"];
    this.userPost_department = map["userPost_department"];
    this.idCard = map["idCard"];
    this.entryTime = map["entryTime"];
    this.factionTime = map["factionTime"];
    this.workingAge = map["workingAge"];
    this.politicsStatus = map["politicsStatus"];
    this.reamName = map["reamName"];
    this.ranking = map["ranking"];
    this.department = map["department"];
    this.autograph = map["autograph"];
    this.userAddress = map["userAddress"];
    this.birthday = map["birthday"];
    this.technicalTitle = map["technicalTitle"];
    this.educationalBackground = map["educationalBackground"];
    this.honoursAwards = map["honoursAwards"];
    this.wrongRule = map["wrongRule"];
    this.mineName = map["mineName"] ?? "--";
    this.userBlocType = map["userBlocType"];
    this.token = map["token"];
    try {
      if (idCard != null) {
        idCard = XORCryptoUtil.decoding(idCard);
      }
    } catch (e) {}
    try {
      if (mobile != null) {
        mobile = XORCryptoUtil.decoding(mobile);
      }
    } catch (e) {}

    try {
      if (reamName != null) {
        reamName = XORCryptoUtil.decoding(reamName);
      }
    } catch (e) {}

    try {
      if (userAddress != null) {
        userAddress = XORCryptoUtil.decoding(userAddress);
      }
    } catch (e) {}
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> map = new Map<String, dynamic>();
    map["userId"] = this.userId;
    map["username"] = this.username;
    map["mobile"] = this.mobile;
    map["sex"] = this.sex;
    map["staffNum"] = this.staffNum;
    map["headImg"] = this.headImg;
    map["userType"] = this.userType;
    map["mineId"] = this.mineId;
    map["userPost"] = this.userPost;
    map["userFaceOpen"] = this.userFaceOpen;

    map["userPost_department"] = this.userPost_department;
    map["idCard"] = this.idCard;
    map["entryTime"] = this.entryTime;
    map["factionTime"] = this.factionTime;

    map["workingAge"] = this.userPost_department;
    map["politicsStatus"] = this.politicsStatus;
    map["reamName"] = this.reamName;
    map["ranking"] = this.ranking;

    map["department"] = this.department;
    map["autograph"] = this.autograph;
    map["userAddress"] = this.userAddress;
    map["birthday"] = this.birthday;

    map["technicalTitle"] = this.technicalTitle;
    map["educationalBackground"] = this.educationalBackground;
    map["honoursAwards"] = this.honoursAwards;
    map["wrongRule"] = this.wrongRule;

    map["mineName"] = this.mineName;
    map["userBlocType"] = this.userBlocType;
    map["token"] = this.token;
    map["isCheck"] = this.isCheck;

    map["userMailbox"] = this.userMailbox;
    map["userAcademy"] = this.userAcademy;
    map["userSchoolNature"] = this.userSchoolNature;
    map["userMajor"] = this.userMajor;
    map["userNation"] = this.userNation;
    map["userResume"] = this.userResume;

    return map;
  }
}
